package com.terrynoya.fight.stateMachine.triggers
{
	import com.terrynoya.fight.animations.IAnimation;
	import com.terrynoya.fight.char.Character;
	import com.terrynoya.fight.evaluation.Node;
	import com.terrynoya.fight.evaluation.ParseState;

	public class AnimTime
	{
		public function AnimTime()
		{
			
		}
		
		public static function eval(data:Object,node:Node):*
		{
			var chara:Character = Character(data);
			if(chara == null)
			{
				return 0;
			}
			
			var ani:IAnimation = chara.animationManager.currentAni
			if(ani == null)
			{
				return 0;
			}
			
			var time:int = chara.animationManager.time;
			if(ani.totalTime == -1)
			{
				return time + 1;
			}
			else
			{
				var rlt:int = time - ani.totalTime;
//trace(chara.id,rlt,time,ani.totalTime,"state",chara.state);
				return rlt;
			}
		}
		
		public static function parse(state:ParseState):Node
		{
			return state.baseNode;
		}
	}
}